home *** CD-ROM | disk | FTP | other *** search
- /* gif2rpcFE.c
- * AUTHOR: Cy Booker, cy@cheepnis.demon.co.uk
- * LICENSE: FreeWare, Copyright (c) 1995 Cy Booker, but see below
- * PURPOSE: pretend to be gif2spr
- * Ie ignore -v and -q flags, and pass rest of command line
- * onto gif2rpc executable
- * assumes gif2rpc is in same directory as this executable
- */
-
- #include <assert.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
-
-
- /* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- */
-
- #define GIF2RPC "chain:%sgif2rpc -gif %s -sprite %s"
-
- /* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- */
-
-
- /* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- */
-
- int main(
- int argc,
- char **argv) {
- const char *sprite = NULL;
- const char *gif = NULL;
- char *app;
- char *rove;
- char *buffer;
- int idx;
-
- argc = argc;
-
- #ifdef DEBUG
- freopen("$.log", "w+", stdout);
- printf("arg[0] = `%s'\n", argv[0]);
- #endif /* DEBUG */
- app = argv[0];
- assert(app);
- for (idx= 1; (argv[idx]); idx++) {
- #ifdef DEBUG
- printf("arg[%d] = `%s'\n", idx, argv[idx]);
- #endif /* DEBUG */
- if ((strcmp(argv[idx], "-v") != 0)
- && (strcmp(argv[idx], "-q") != 0)) {
- if (gif == NULL) {
- gif = argv[idx];
- } else {
- assert(sprite == NULL);
- sprite = argv[idx];
- }
- }
- }
- #ifdef DEBUG
- printf("gif = `%s'\n", gif);
- printf("sprite = `%s'\n", sprite);
- #endif /* DEBUG */
- assert(gif);
- assert(sprite);
- /*
- * search for end of directory part of path name
- * because we are assuming the gif2rpc executable is in the
- * same directory as (this) gif2rpcFE executable
- */
- rove = strrchr(app, '.');
- if (!rove) {
- /*
- * cope with `path's
- */
- rove = strrchr(app, ':');
- }
- if (rove) {
- rove[1] = '\0';
- } else {
- /*
- * implicit path (csd)
- */
- app[0] = '\0';
- }
- buffer = malloc(strlen(app) + strlen(GIF2RPC) + strlen(gif) + strlen(sprite));
- assert(buffer);
- sprintf(buffer, GIF2RPC, app, gif, sprite);
- #ifdef DEBUG
- printf("launching: `%s'\n", buffer);
- #endif /* DEBUG */
- system(buffer);
- return EXIT_SUCCESS;
- }
-